﻿<Table DataSource="data" Bordered HidePagination>
    <Column Title="Name" DataIndex="name" TData="string"></Column>
    <Column Title="Borrow" DataIndex="borrow" TData="int"></Column>
    <Column Title="Repayment" DataIndex="repayment" TData="int"></Column>
@{
    var totalBorrow = data.Sum(x => x.borrow);
    var totalRepayment = data.Sum(x => x.repayment);
}    
    <SummaryRow>
        <SummaryCell>Total</SummaryCell>
        <SummaryCell>
            <Text Type="danger">@totalBorrow</Text>
        </SummaryCell>
        <SummaryCell>
            <Text Type="danger">@totalRepayment</Text>
        </SummaryCell>
    </SummaryRow>
    <SummaryRow>
        <SummaryCell>Balance</SummaryCell>
        <SummaryCell ColSpan="2">
            <Text Type="danger">@(totalBorrow - totalRepayment)</Text>
        </SummaryCell>
    </SummaryRow>
</Table>

<br/>

<Table DataSource="fixedData" ScrollX="2000" Bordered HidePagination>
    <Column Title="Name" DataIndex="name" TData="string" Fixed="left" Width="100"></Column>
    <Column Title="Description" DataIndex="description" TData="string"></Column>
    <SummaryRow>
        <SummaryCell Fixed="left">Summary</SummaryCell>
        <SummaryCell>This is a summary content</SummaryCell>
    </SummaryRow>
</Table>

@code {

    record Data(string key, string name, int borrow, int repayment);

    Data[] data = new Data[]
    {
        new("1","John Brown",10,33),
        new("2","Jim Green",100,0),
        new("3","Joe Black",10,10),
        new("4","Jim Red",75,45),
    };

    record FixedData(string name,string description);

    FixedData[] fixedData = Enumerable.Range(0, 6)
        .Select(i => new FixedData(
               name: (i % 2) > 0 ? "Light" : "Bamboo", 
               description: "Everything that has a beginning, has an end.")
        ).ToArray();
}

